package com.project.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.project.bean.RoleBean;
import com.project.service.IRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("role")
public class RoleController {
    @Autowired
    private IRoleService roleService;
    @RequestMapping("findAll")
    public List<RoleBean> findAll() {
        return roleService.findAll();
    }
    @RequestMapping("findByItem")
    public IPage<RoleBean> findByItem(Integer pageNO) {

        return roleService.findByItem(pageNO);
    }
    @RequestMapping("add")
    public String  add(RoleBean role, Integer[] powerIdArray) {
           roleService.add(role, powerIdArray);
           return "ok";
    }
    @RequestMapping("del")
    public String del(Integer id) {
      roleService.del(id);
      return "ok";
    }

    @RequestMapping("findById")
    public RoleBean findById(Integer id) {
       return roleService.findById(id);
    }

    @RequestMapping("update")
    public String update(Integer id, Integer[] powerIdArray) {
        roleService.update(id, powerIdArray);
        return "ok";
    }
}
